package com.santana.parser.googleMovie;

import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;

import com.santana.icine.Response;

public class GoogleReader {

	public Response getMovies(String location) {

		Response response = new Response();
		
		try {

			URL url = new URL("http://www.google.com/movies?near="
					+ URLEncoder.encode(location, "UTF-8"));
			url.openConnection();
			
			response.setLocation(location);
			
			HTMLParser parser = new HTMLParser();
			List<String> movies = parser.getElements(url, null, null);

			response.setMovies(movies);

		} catch (Exception e) {
			e.printStackTrace();
		}

		return response;
	}
}
